class PWNPlayerInput extends UTPlayerInput;

//Jump
var int numberOfJumps;
var int numberOfJumpsRequired;
var float JumpStatsIncreaseAmount;

//Speed
var int numberOfDucks;
var int numberOfDucksRequired;
var float SpeedStatsIncreaseAmount;

//Health
var int numberOfKeypressesHealth;
var int numberOfKeypressesHealthRequired;
var float HealthStatsIncreaseAmount;

//Time Dilation
var int numberOfKeypressesTimeDilation;
var int numberOfKeypressesTimeDilationRequired;
var float TimeDilationStatsIncreaseAmount;
var() bool TimeDilated;

//Time Dilation Duration
var int numberOfKeypressesTimeDilationDuration;
var int numberOfKeypressesTimeDilationDurationRequired;
var float TimeDilationDurationStatsIncreaseAmount;
var float TimeDilationDurationTimeSinceLastUse;
var bool TimeDilationDurationMustStop;





//Debug Print Function for this class
simulated public function PWNInputDebugPrint(string sMessage)
{
	GetALocalPlayerController().ClientMessage(sMessage);
}


//Jumping specified number of times increases player's jump height & distance
exec simulated function Jump()
	{	
		Super.Jump();	

		//Test Start a quest
		StartAQuest();



		/**HolyGRAIL!!!!!!!*/
		//PWNPawn(Pawn).StatsJumpIncrease();
		/*******************/		

		if(PWNPawn(Pawn).StatsLevelJump<PWNPawn(Pawn).StatsLevelJumpMax)
		{
			if(numberOfJumps<numberOfJumpsRequired)
			{
				
				numberOfJumps++;						
				PWNInputDebugPrint("Jumps still required for next level: " $(numberOfJumpsRequired-numberOfJumps));
				
				if(numberOfJumps==numberOfJumpsRequired)
				{
					PWNPawn(Pawn).StatsIncrJump();
					PWNPawn(Pawn).StatsLevelIncrJump();
					

					if (PWNPawn(Pawn).StatsLevelJump==PWNPawn(Pawn).StatsLevelJumpMax)
					{
						PWNInputDebugPrint("Maximum jump level reached for this map.");
						
					}
					
				}
			}
		}		
		
	}


//Ducking specified number of times increases player's movement speed
exec simulated function Duck()
	{
		super.Duck();

		if(PWNPawn(Pawn).StatsLevelSpeed<PWNPawn(Pawn).StatsLevelSpeedMax)
		{
			if(numberOfDucks<numberOfDucksRequired)
			{
				numberOfDucks++;
				ClientMessage("Ducks still required: " $(numberOfDucksRequired-numberOfDucks));// +" times.");
			}
				
			if(numberOfDucks==numberOfDucksRequired)
			{
				PWNPawn(Pawn).StatsIncrSpeed();
				PWNPawn(Pawn).StatsLevelIncrSpeed();
				numberOfDucks=0;

				if (PWNPawn(Pawn).StatsLevelSpeed == PWNPawn(Pawn).StatsLevelSpeedMax)
				{
					PWNInputDebugPrint("Maximum speed level reached for this level.");
				}
			}

			
			
		}

		
		
	}

exec function StatsHealthIncreaseCMD()
{		
	if(PWNPawn(Pawn).StatsLevelHealth < PWNPawn(Pawn).StatsLevelHealthMax)
		{
			if(numberOfKeypressesHealth < numberOfKeypressesHealthRequired)
			{
				numberOfKeypressesHealth++;
				ClientMessage("Keypresses still required: " $(numberOfKeypressesHealthRequired - numberOfKeypressesHealth));// +" times.");
			}

			if(numberOfKeypressesHealth == numberOfKeypressesHealthRequired)
			{
				PWNPawn(Pawn).StatsIncrHealth();
				PWNPawn(Pawn).StatsLevelIncrHealth();
				numberOfKeypressesHealth=0;

				if (PWNPawn(Pawn).StatsLevelHealth == PWNPawn(Pawn).StatsLevelHealthMax)
				{
					PWNInputDebugPrint("Maximum health level reached for this level.");
				}
			}
		}

	
			
		
}

exec function DisplayStatsCMD()
{	
	PWNPawn(Pawn).StatsPrintAll();	
}

exec function DisplayStatsLevelsCMD()
{
	PWNPawn(Pawn).StatsLevelPrintAll();	
}

exec function MonsterStateToggleCMD()
{
	if (PWNPlayerController(GetALocalPlayerController()).PlayerIsMonster)
	{
		PWNPlayerController(GetALocalPlayerController()).MonsterStateDeactivate();
	}
	else
	{
		PWNPlayerController(GetALocalPlayerController()).MonsterStateActivate();
	}
}

function TimeDilationStop()
{
	PWNPlayerController(GetALocalPlayerController()).TimeDilationIsRunning = false;
	WorldInfo.TimeDilation = 1;
	TimeDilated = false;
}

function TimeDilationStart()
{
	PWNPlayerController(GetALocalPlayerController()).TimeDilationIsRunning = true;
	WorldInfo.TimeDilation = PWNPawn(Pawn).StatsTimeDilation;		
	TimeDilated = true;	
}

exec function TimeDilationToggleCMD()
{
	TimeDilated = PWNPlayerController(GetALocalPlayerController()).TimeDilationIsRunning;
	if (TimeDilated)
	{
		TimeDilationStop();		
	}

	else
	{		
		TimeDilationStart();		

		if (PWNPawn(Pawn).StatsLevelTimeDilation < PWNPawn(Pawn).StatsLevelTimeDilationMax)
		{
			if (numberOfKeypressesTimeDilation < numberOfKeypressesTimeDilationRequired)
			{
				numberOfKeypressesTimeDilation++;
				ClientMessage("Keypresses still required: " $(numberOfKeypressesTimeDilationRequired - numberOfKeypressesTimeDilation));// +" times.");
			}

			if (numberOfKeypressesTimeDilation == numberOfKeypressesTimeDilationRequired)
			{	
				//Increase the amount of dilation
				PWNPawn(Pawn).StatsIncrTimeDilation();
				PWNPawn(Pawn).StatsLevelIncrTimeDilation();

				//Increase the duration of dilation
				PWNPawn(Pawn).StatsIncrTimeDilationDuration();
				PWNPawn(Pawn).StatsLevelIncrTimeDilationDuration();

				numberOfKeypressesTimeDilation = 0;

				if (PWNPawn(Pawn).StatsLevelTimeDilation < PWNPawn(Pawn).StatsLevelTimeDilationMax)
				{
					PWNInputDebugPrint("Maximum time dilaiton level reached for this level.");
				}
			}
		}		
	}



}

function StartAQuest()
{	
	local PWNQuest a;
	a.StartQuest();
}

	//WorldInfo.TimeDilation = 0.5;	


DefaultProperties
{
	numberOfJumpsRequired=5
	numberOfJumps=0
	JumpStatsIncreaseAmount=150

	numberOfDucksRequired=5
	numberOfDucks=0
	SpeedStatsIncreaseAmount=200

	numberOfKeypressesHealthRequired=5
	numberOfKeypressesHealth=0
	HealthStatsIncreaseAmount=200;

	numberOfKeypressesTimeDilationRequired=3
	numberOfKeypressesTimeDilation=0
	TimeDilationStatsIncreaseAmount=-0.2;

	numberOfKeypressesTimeDilationDurationRequired=3
	numberOfKeypressesTimeDilationDuration=0
	TimeDilationDurationStatsIncreaseAmount=-0.2;

	TimeDilationDurationTimeSinceLastUse=0.0
	TimeDilationDurationMustStop=false


	//bInvertMouse = true;
}
